热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Python|熊猫PeriodIndex.week

Python|熊猫PeriodIndex.week原文:htt

Python|熊猫 PeriodIndex.week

原文:https://www . geesforgeks . org/python-pandas-period index-week/

Python 是进行数据分析的优秀语言,主要是因为以数据为中心的 python 包的奇妙生态系统。 【熊猫】 就是其中一个包,让导入和分析数据变得容易多了。

Pandas **PeriodIndex.week**属性返回一个 Index 对象,该对象包含给定 PeriodIndex 对象的每个周期元素的周序数值。

语法: PeriodIndex.week

参数:

返回:索引对象

示例#1: 使用PeriodIndex.week属性找出给定 PeriodIndex 对象中包含的每个 period 元素的周序数值。

# importing pandas as pd
import pandas as pd
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2004-11-11 02:45:21 ', 
               end ='2004-11-21 8:45:29', freq ='D')
# Print the PeriodIndex object
print(pidx)

输出:

现在我们将使用PeriodIndex.week属性找出给定 PeriodIndex 对象在一年中的周序数值。

# return the week's ordinal value
pidx.week

输出:

正如我们在输出中看到的那样,PeriodIndex.week属性返回了一个 Index 对象,该对象包含给定 PeriodIndex 对象中包含的每个 period 元素的周序数值。

示例#2: 使用PeriodIndex.week属性找出给定 PeriodIndex 对象中包含的每个 period 元素的周序数值。

# importing pandas as pd
import pandas as pd
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2016-2-12 11:12:02', 
           end ='2016-09-12 11:32:12', freq ='M')
# Print the PeriodIndex object
print(pidx)

输出:

现在我们将使用PeriodIndex.week属性找出给定 PeriodIndex 对象在一年中的周序数值。

# return the week's ordinal value
pidx.week

输出:

正如我们在输出中看到的那样,PeriodIndex.week属性返回了一个 Index 对象,该对象包含给定 PeriodIndex 对象中包含的每个 period 元素的周序数值。


推荐阅读
author-avatar
晓风朗月
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有